package problems.daily;

/**
 * 754. 到达终点数字
 * <p>https://leetcode.cn/problems/reach-a-number/</p>
 *
 * @author habitplus
 * @since 2022/11/4 13:00
 */
public class DT754 {
    public int reachNumber(int target) {
        target = Math.abs(target);
        int k = 0;
        while (target > 0) {
            k++;
            target -= k;
        }
        return target % 2 == 0 ? k : k + 1 + k % 2;
    }
}
